From 16651e108bb69a41a62b6823baf93a540913570f Mon Sep 17 00:00:00 2001 From: Alastair Tse Date: Thu, 30 Nov 2006 15:19:01 +0000 Subject: [PATCH] [XEND] Catch TypeErrors when unexpected SXP is encountered. Signed-off-by: Alastair Tse --- tools/python/xen/xend/XendConfig.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py index e4143cc390..5b54d79c26 100644 --- a/tools/python/xen/xend/XendConfig.py +++ b/tools/python/xen/xend/XendConfig.py @@ -398,14 +398,14 @@ class XendConfig(dict): for key in extract_keys: val = sxp.child_value(sxp_cfg, key) - if val: + if val != None: try: - try: - cfg[key] = LEGACY_CFG_TYPES[key](val) - except KeyError: - cfg[key] = val - except ValueError: - pass + cfg[key] = LEGACY_CFG_TYPES[key](val) + except KeyError: + cfg[key] = val + except (TypeError, ValueError), e: + log.warn("Unable to parse key %s: %s: %s" % + (key, str(val), e)) # Parsing the device SXP's. In most cases, the SXP looks # like this: @@ -463,7 +463,7 @@ class XendConfig(dict): image_sxp = sxp.child_value(sxp_cfg, 'image', []) if image_sxp: image_vcpus = sxp.child_value(image_sxp, 'vcpus') - if image_vcpus is not None: + if image_vcpus != None: try: if 'vcpus_number' not in cfg: cfg['vcpus_number'] = int(image_vcpus) -- 2.30.2